//
//  DDOpenDetailViewController.m
//  LYJR_XDD
//
//  Created by 肖棟棟 on 16/8/6.
//  Copyright © 2016年 肖棟棟. All rights reserved.
//

#import "DDOpenDetailViewController.h"
#import "DDCompleteViewController.h"

@interface DDOpenDetailViewController ()

//手机号文本
@property (nonatomic, strong) UILabel *phoneLb;

//验证码view
@property (nonatomic, strong) UIView *phoneView;
//验证码textField
@property (nonatomic, strong) UITextField *verifyTextField;

//重获取验证码
@property (nonatomic, strong) UIButton *regetVerifyBtn;
//密码view
@property (nonatomic, strong) UIView *passwordView;
//密码textfiled
@property (nonatomic, strong) UITextField *passwordTextField;
//下一步
@property (nonatomic, strong) UIButton *nextBtn;






@end

@implementation DDOpenDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor colorWithHexColor:@"#090B21"];
    
    [self createUI];
    [self setNavButton];
}


-(void)createUI{
    
    UIImageView *verifyImageView = [[UIImageView alloc]init];
    verifyImageView.image = [UIImage imageNamed:@"iPhone 6 Copy 14"];
    
    UIImageView *passwordImageView = [[UIImageView alloc]init];
    passwordImageView.image = [UIImage imageNamed:@"Group 4"];
    
    [self.view addSubview:self.phoneLb];
    [self.view addSubview:self.phoneView];
    [self.view addSubview:verifyImageView];
    [self.view addSubview:self.verifyTextField];
    [self.view addSubview:self.regetVerifyBtn];
    [self.view addSubview:self.passwordView];
    [self.view addSubview:passwordImageView];
    [self.view addSubview:self.passwordTextField];
    [self.view addSubview:self.nextBtn];
    
    [_phoneLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view).offset(25+64);
        make.left.mas_equalTo(self.view).offset(15);
        
    }];
    
    [_phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_phoneLb.mas_bottom).offset(15);
        make.left.mas_equalTo(_phoneLb);
        make.width.mas_equalTo(180);
        make.height.mas_equalTo(50);
    }];
    [verifyImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_phoneView).offset(12);
        make.bottom.mas_equalTo(_phoneView).offset(-12);
        make.left.mas_equalTo(_phoneView).offset(10);
        make.width.mas_equalTo(verifyImageView.mas_height);
    }];
    
    [_verifyTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(verifyImageView);
        make.left.mas_equalTo(verifyImageView.mas_right).offset(10);
        make.right.mas_equalTo(_phoneView);
    }];
    
    [_regetVerifyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(_phoneView);
        make.left.mas_equalTo(_phoneView.mas_right).offset(10);
        make.right.mas_equalTo(self.view).offset(-15);
    }];
    
    [_passwordView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_phoneView.mas_bottom).offset(15);
        make.height.mas_equalTo(_phoneView);
        make.left.mas_equalTo(self.view).offset(15);
        make.right.mas_equalTo(self.view).offset(-15);
    }];
    [passwordImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_passwordView).offset(12);
        make.bottom.mas_equalTo(_passwordView).offset(-12);
        make.left.mas_equalTo(_passwordView).offset(10);
        make.width.mas_equalTo(passwordImageView.mas_height);
    }];
    [_passwordTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(passwordImageView);
        make.left.mas_equalTo(passwordImageView.mas_right).offset(10);
        make.right.mas_equalTo(_passwordView);
    }];
    
    [_nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_passwordView.mas_bottom).offset(15);
        
        make.right.left.height.mas_equalTo(_passwordView);
    }];
    
}

#pragma mark - 私有方法

-(void)setNavButton{
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Group 51"] style:UIBarButtonItemStylePlain target:self action:@selector(backBtnDidClick)];
}

-(void)backBtnDidClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)regetVerifyBtnDidClick{
    NSLog(@"xxx");
}

-(void)nextBtnBtnDidClick{
    NSLog(@"next");
    
    if ([self.title isEqualToString:@"验证详情"]) {
        return;
    }
    DDCompleteViewController * comVC =[[DDCompleteViewController alloc] init];
    [self.navigationController pushViewController:comVC animated:YES];
    
}





#pragma mark - setter 和  getter

-(void)setPhoneNum:(NSString *)phoneNum
{
    _phoneNum = phoneNum;
}

-(UILabel *)phoneLb{
    if (_phoneLb == nil) {
        _phoneLb = [[UILabel alloc] init];
        _phoneLb.text = [NSString stringWithFormat:@"已发送验证码到：%@",self.phoneNum];
        _phoneLb.textColor = [UIColor colorWithHexColor:@"#FFFFFF"];
        _phoneLb.font =[UIFont systemFontOfSize:18];
        
    }
    return _phoneLb;
}

-(UIView *)phoneView{
    if (_phoneView == nil) {
        _phoneView = [[UIView alloc] init];
                _phoneView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"yan zheng tian kuang"]];
//        _phoneView.backgroundColor = [UIColor whiteColor];
        
    }
    return _phoneView;
}

- (UITextField *)verifyTextField{
    if (_verifyTextField == nil) {
        _verifyTextField = [[UITextField alloc]init];
        _verifyTextField.textColor = [UIColor colorWithHexColor:@"#66666B"];
        _verifyTextField.placeholder = @"验证码";
        _verifyTextField.keyboardType = UIKeyboardTypeNumberPad;
        _verifyTextField.font = [UIFont systemFontOfSize:15];
        [_verifyTextField setValue:[UIColor colorWithHexColor:@"#66666B"] forKeyPath:@"_placeholderLabel.textColor"];
        
    }return _verifyTextField;
}
-(UIButton *)regetVerifyBtn{
    
    if (_regetVerifyBtn == nil) {
        _regetVerifyBtn = [[UIButton alloc] init];
        [_regetVerifyBtn setTitleColor:[UIColor colorWithHexColor:@"#FFCB6F"] forState:UIControlStateNormal];
        [_regetVerifyBtn setTitle:@"重获验证码" forState:UIControlStateNormal];
        _regetVerifyBtn.titleLabel.font=[UIFont systemFontOfSize:12];
        [_regetVerifyBtn setBackgroundImage:[UIImage imageNamed:@"yanzhengkuang"] forState:UIControlStateNormal];
        [_regetVerifyBtn addTarget:self action:@selector(regetVerifyBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _regetVerifyBtn;
}
-(UIView *)passwordView{
    if (_passwordView == nil) {
        _passwordView = [[UIView alloc] init];
        _passwordView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"690 100 131 Copy"]];
        //        _passwordView.backgroundColor = [UIColor whiteColor];
    }
    return _passwordView;
}

- (UITextField *)passwordTextField{
    if (_passwordTextField == nil) {
        _passwordTextField = [[UITextField alloc]init];
        _passwordTextField.placeholder = @"设置登录密码，至少六位数";
        _passwordTextField.font = [UIFont systemFontOfSize:15];
        _passwordTextField.secureTextEntry = YES;
       [_passwordTextField setValue:[UIColor colorWithHexColor:@"#66666B"] forKeyPath:@"_placeholderLabel.textColor"];
        
        _passwordTextField.textColor= [UIColor colorWithRed:96/255.0 green:96/255.0 blue:104/255.0 alpha:1];
    }return _passwordTextField;
}

-(UIButton *)nextBtn{
    if (_nextBtn== nil) {
        _nextBtn = [[UIButton alloc] init];
        [_nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
        _nextBtn.titleLabel.font=[UIFont systemFontOfSize:18];
        [_nextBtn setTitleColor:[UIColor colorWithHexColor:@"#191A27"] forState:UIControlStateNormal];
        [_nextBtn setBackgroundImage:[UIImage imageNamed:@"Rectangle 184"] forState:UIControlStateNormal];
        
        [_nextBtn addTarget:self action:@selector(nextBtnBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _nextBtn;
}

@end
